<template>
  <nf-form
    v-form-drag="extendFormProps"
    :model="_meta"
    :partModel="_partMeta"
    v-bind="extendFormProps"
  >
  </nf-form>
</template>

<script>
import { reactive, watch } from 'vue'
import { nfForm } from '../mapUI'
import { extendSetup } from './miniMeta'
import { state } from '../main'

import item_check from '../json/item-checks.json'

const _temp = {
  150: `<el-checkbox
  v-model="checkbox"
  v-bind="itemProps"
/>`,
  151: `<el-switch
  v-model="switch"
  v-bind="itemProps"
/>`,
  152: `<el-checkbox-group
  v-model="checkboxs"
  v-bind="itemProps"
>
  <el-checkbox
    v-for="item in itemProps.optionList"
    :key="'check' + columnId + item.value"
    :label="item.value"
    :disabled="item.disabled"
  >
    {{item.label}}
  </el-checkbox>
</el-checkbox-group>`,
  153: `<el-radio-group
  v-model="radios"
  v-bind="itemProps"
>
  <el-radio
    v-for="item in itemProps.optionList"
    :key="'radio' + columnId + item.value"
    :label="item.value">
      {{item.label}}
  </el-radio>
</el-radio-group>`
  
}
</script>

<script setup>
 // 定义属性，接收传递来的 meta
  const props = defineProps({
    temp: Object, // 返回模板
    miniMeta: Object,
    mainMeta: Object
  })
  
  // 设置模板
  watch(() => state.itemMeta.controlType, (type) => {
    state.outputItem.temp.html = _temp[type]
    state.outputItem.temp.name = 'itemProps'
  }, {immediate: true})
  
  // 文本类扩展属性表单，需要的 meta
  const extendFormProps = reactive(item_check)
 
  const {
    _meta,
    _partMeta
  } = extendSetup(props, item_check.itemMeta)

</script>